package com.corechina.apex_osswords.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.corechina.apex_osswords.common.Response;
import com.corechina.apex_osswords.domain.entity.CoreClientele;
import com.corechina.apex_osswords.domain.dao.CoreClienteleMapper;
import com.corechina.apex_osswords.domain.vo.CoreClienteleVo;
import com.corechina.apex_osswords.service.ICoreClienteleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 客户信息表 服务实现类
 * </p>
 *
 * @author cc
 * @since 2022-03-11
 */
@Service
public class CoreClienteleServiceImpl extends ServiceImpl<CoreClienteleMapper, CoreClientele> implements ICoreClienteleService {

    @Autowired
    private CoreClienteleMapper coreClienteleMapper;

    @Override
    public Response getList(String name, String company, Integer pageIndex, Integer pageSize) {
        IPage<CoreClienteleVo> coreClienteleVoIPage = coreClienteleMapper.getList(new Page(pageIndex, pageSize), name, company);
        return Response.ok(coreClienteleVoIPage.getRecords(), coreClienteleVoIPage.getTotal());
    }

    @Override
    public Response getOne(Integer id) {
        return Response.ok(coreClienteleMapper.getOne(id));
    }
}
